<?php
/**
 * Defines the Vessel page type
 */
 
class VesselPage extends SecurePage {
 
}
 
class VesselPage_Controller extends SecurePage_Controller {

	function VesselForm() {
      
		// Create fieldset containing fields
		$fields = new FieldSet(
		new TextField('Vessel_Name', 'Vessel Name'),
		new TextField('Vessel_Rego', 'Vessel Registration')
		);
 
		// Create action for form submission
		$actions = new FieldSet(new FormAction('submitVessel', 'Submit'));
	  
		// Set required fields
		$validator = new RequiredFields('Vessel_Name', 'Vessel_Rego');
 
		return new Form($this, 'VesselForm', $fields, $actions, $validator);
   }

	function submitVessel($data, $form) {
		// Save form data into new Vessel object and write to database
		$submission = new Vessel();
		$form->saveInto($submission);
		$submission->write();
 
		Director::redirectBack();
	}

}
?>